package Test_07_03;

import java.util.Scanner;

//射击游戏中往往涉及各种刚体（形状不改变的物体），
// 例如正方形盒子物体，也会有各种针对刚体的计算，
// 例如子弹击中物体，可以认为子弹坐标落在物体范围内。
// 请设计刚体（多种形状）信息管理系统，目前包括圆形物体和正方形物体，为便于将来扩展采用接口设计刚体计算功能。
//1、设计射击类（Shooter）， 含有成员刚体RigidBody,方法useRigid(RigidBody o)注入射击操作的刚体对象；
//2、设计刚体操作接口RigidOp，包含一个判断子弹（坐标点）是否在刚体范围内的方法boolean judgeIn(int pointx,int pointy)；
//3、设计刚体类RigidBody，包含一个成员：刚体名称，并且实现刚体操作接口RigidOp。
//4、设计正方形刚体类SquareBody（成员包括左上角和右下角横纵坐标）和圆形刚体类CircleBody（成员包括圆心坐标和半径）继承刚体类RigidBody。
//5、主函数和电脑类部分函数如下：
//public class mainClass {
//	public static void main(String[] args) {
//		// TODO Auto-generated method stub
//		Scanner sc=new Scanner(System.in);
//		int bulletx=sc.nextInt();
//		int bullety=sc.nextInt();
//		Shooter game = new Shooter();
//		game.useRigid(new SquareBody("box",10,10,100,100));
//		game.shoot(bulletx, bullety);
//		game.useRigid(new CircleBody("ball",150,150,10));
//		game.shoot(bulletx, bullety);
//		}
//}
//注意：修改主函数或者不按要求实现接口都不得分。
//输入
//游戏中子弹的坐标x,y（这里采用的都是屏幕坐标，即都是正整数，屏幕左上角为坐标（0，0））
//输出
//若子弹击中某个刚体，输出“yes!shooted ”+刚体名称；否则，输出“sorry,missed”+刚体名称。
//难度
//入门
//输入示例
//20 20
//输出示例
//yes!shooted box
//sorry!missed ball
interface RigidOp
{
    boolean judgeIn(int pointx, int pointy);
}

abstract class RigidBody implements RigidOp
{
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public RigidBody(String name) {
        this.name = name;
    }

    public abstract boolean judgeIn(int pointx, int pointy);
}

class SquareBody extends RigidBody
{
    private int x1, x2, y1, y2;

    public SquareBody(String name, int x1, int x2, int y1, int y2) {
        super(name);
        this.x1 = x1;
        this.x2 = x2;
        this.y1 = y1;
        this.y2 = y2;
    }


    @Override
    public boolean judgeIn(int pointx, int pointy) {
        return pointx >= x1 && pointx <= x2 && pointy >= y1 && pointy <= y2;
    }
}

class CircleBody extends RigidBody
{
    private int centerx, centery;
    private int radius;

    public CircleBody(String name, int centerx, int centery, int radius) {
        super(name);
        this.centerx = centerx;
        this.centery = centery;
        this.radius = radius;
    }

    @Override
    public boolean judgeIn(int pointx, int pointy)
    {
        int dx = pointx - centerx;
        int dy = pointy - centery;
        return dx * dx + dy * dy <= radius * radius;
    }
}

class Shooter
{
    private RigidBody rigidBody;
    // 转换
    public void useRigid(RigidBody o)
    {
        rigidBody = o;
    }
    public void shoot (int shootx, int shooty)
    {
        if(rigidBody.judgeIn(shootx, shooty))
        {
            System.out.println("yes!shooted " + rigidBody.getName());
        }else {
            System.out.println("sorry,missed " + rigidBody.getName());
        }
    }
}

public class Main3 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int bulletx=sc.nextInt();
        int bullety=sc.nextInt();
        Shooter game = new Shooter();
        game.useRigid(new SquareBody("box",10,10,100,100));
        game.shoot(bulletx, bullety);
        game.useRigid(new CircleBody("ball",150,150,10));
        game.shoot(bulletx, bullety);
    }
}
